package xdu.ble.user.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * @Author com.alibaba.lizhen
 * @Date 2021/1/13 7:49 下午
 * @Version 1.0
 * @Description 管理员表
 */
@Table(name = "hospital_admin_info")
@Data
public class Admin implements Serializable {


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Length(min = 2,max = 10,message = "名字只能在2-10位之间")
    private String userName;

    @JsonIgnore
    private String passWord;

    @Length(min = 18,max = 18,message = "身份证有误")
    private String idCard;

    //密码盐值
    @JsonIgnore
    private String salt;


    //TODO 角色类型，不同类型有不同权限
    //private String roleType;

    @Pattern(regexp = "^1[35678]\\d{9}$",message = "手机格式有误")
    private String phoneNum;

    //所属医院
    private String hospital;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date latestLoginTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date registerTime;

    /**
     * 角色权限，目前只有admin和superAdmin两种
     * TODO
     */
    @JsonIgnore
    private String roleType;
}
